import 'package:ffloat/ffloat.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/config/colors.dart';
import 'package:flutter_demo/config/dimens.dart';
import 'package:flutter_demo/provider/globle_model.dart';
import 'package:flutter_demo/provider/home_page_model.dart';
import 'package:flutter_demo/provider_widget.dart';
import 'package:flutter_demo/util/screen_util.dart';
import 'package:flutter_demo/widget/toolbar.dart';
import 'package:fradio/fradio.dart';
import 'package:fsuper/fsuper.dart';
import 'package:provider/provider.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  GlobalKey<ScaffoldState> _key = GlobalKey<ScaffoldState>();
  List<String> clickList = ['dianwo', 'budianwo'];

  @override
  Widget build(BuildContext context) {
    final globmodel = Provider.of<GlobalModel>(context);
    return ProviderWidget<HomePageModel>(
      model: HomePageModel(),
      builder: (context, model, child) {
        return Scaffold(
          appBar: Toolbar(
            title: Text(
              '首页',
              style: Dimens.style36_28,
            ),
            actions: [
              FFloat(
                    (setter) {
                  return Container(
                    height: 100,
                    width: 100,
                    child: ListView.builder(
                        shrinkWrap: true,
                        padding: EdgeInsets.zero,
                        itemCount: clickList.length,
                        itemBuilder: (context, index) {
                          return FRadio.custom(
                            value: index,
                            groupValue: 0,
                            onChanged: (value) {
                              setter(() {
                                model.floatController.dismiss();
//                              clickCallBack(value);
//                              group_vule = value;
                              });
                            },
                            normal: FSuper(
                              width: double.infinity,
                              height: ScreenAdaptive.height(50),
                              textAlign: TextAlign.center,
                              textAlignment: Alignment.center,
                              text: clickList[index],
                              style: TextStyle(
                                  color: Colours.color_28,
                                  fontSize: ScreenAdaptive.sp(30)),
                            ),
                            selected: FSuper(
                              width: double.infinity,
                              height: ScreenAdaptive.height(50),
                              textAlign: TextAlign.center,
                              textAlignment: Alignment.center,
                              text: clickList[index],
                              style: TextStyle(
                                  color: Colours.redColor,
                                  fontSize: ScreenAdaptive.sp(30)),
                              backgroundColor: Colors.white,
                            ),
                          );
                        }),
                  );
                },
                anchor: Container(
                  margin: EdgeInsets.only(bottom: 5),
                  width: 80,
                  child: Center(child: Text('点我 ')),
                ),
                alignment: FFloatAlignment.bottomCenter,
              )
            ],
            leading: FlatButton(
                onPressed: () {
                  globmodel.globalKey.currentState.openDrawer();
                },
                child: Icon(Icons.menu)),
          ),
          body: Container(
            child: Center(
            ),
          ),
        );
      },
    );
  }
}
